gusucode.com > 支持向量机工具箱 - LIBSVM OSU_SVM LS_SVM源码程序 > 支持向量机工具箱 - LIBSVM OSU_SVM LS_SVM\stprtool\generalp\cliplin2.m
function [x,y]=cliplin2(alpha,window) % [x,y]=cliplin2(alpha,window) % % CLIPLIN2 clips the line going from pixel [0,0] to pixel on % the border of the rectangle given by the argument window. % The direction of the line is given by the argument alpha. % This function returns coordinates of the mentioned pixel % on the border. % % See also CLIPLIN1. % % Statistical Pattern Recognition Toolbox, Vojtech Franc, Vaclav Hlavac % (c) Czech Technical University Prague, http://cmp.felk.cvut.cz % Written Vojtech Franc (diploma thesis) 12.10.1999 % Modifications % 24. 6.00 V. Hlavac, comments polished. % get window`s left side, right side, bottom... minx=window(1); maxx=window(2); miny=window(3); maxy=window(4); if alpha(1) >= 0, ax = maxx; else ax = minx; end if alpha(2) >= 0, ay = maxy; else ay = miny; end if alpha(2) == 0, x = ax; else x = alpha(1)*ay/alpha(2); end if alpha(1) == 0, y = ay; else y = alpha(2)*ax/alpha(1); end if (x^2+ay^2) <= (ax^2+y^2), y = ay; else x = ax; end